import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex);

export default new Vuex.Store({
    //用于保存状态的store
    state: {
        isLogined: false,
        isLoading: false,
        token: undefined,
        draweritems: [
            { title: '主页', to: '/home', icon: 'mdi-account-circle' },
            { title: '反馈列表', to: '/list', icon: 'mdi-view-list' },
            { title: '登录', to: '/login', icon: 'mdi-account-circle' },
        ],
		wants: []
    },

    //传值操作
    mutations: {
        loading: (state, payload) => {
            state.isLoading = payload
        },
        login: (state, payload) => {
            state.isLogined = payload
        },
        draweritems: (state, payload) => {
            state.draweritems = payload
        },
        token: (state, payload) => {
            state.token = payload
        },
		want: (state, payload) => {
			state.wants.push(payload)
		}
    },
    plugins: [createPersistedState()]
});